/*
 * HotelTest.java
 *
 * This program uses the classes Hotel and RoomsNotAvailableException to
 * demonstrate the concept of user-defined exceptions.
 *
 * 
 */

package com.javacore.day9.hotel;

import java.util.Scanner;

/**
 * HotelTest class allows a user to book rooms and change total number of rooms
 * in the hotel.
 * @author 
 */
public class HotelTest {
    
    /**
     * Creates a new instance of HotelTest
     */
    public HotelTest() {
    }
    
    /**
     * This is the entry point of the application.
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        // Create an instance of class Hotel to book rooms
        Hotel objBeach = new Hotel();
        
        Scanner input = new Scanner(System.in);
        
        // Variable to store the task selected by the user
        String choice = "";
        
        // Iterate until the user chooses to exit the application
        while(!choice.equals("3")) {
            
            // Display the menu
            System.out.println("\nWelcome to Hotel Beach International.\n" +
                    "Select a task you want to perform:");
            System.out.println("******************************************");
            
            System.out.println("1. Change the total number of rooms");
            System.out.println("2. Book one or more rooms");
            System.out.println("3. Exit");
            System.out.println("******************************************");
            
            System.out.println("Enter your choice:");
            choice = input.next();
            
            try {
                // Invoke the method of Hotel class depending on the task
                // selected by the user
                if (choice.equals("1")) {
                    objBeach.setCapacity();
                } else if(choice.equals("2")) {
                    objBeach.bookRooms();
                } else if(choice.equals("3")) {
                    return;
                } else {
                    System.out.println("\nInvalid choice.");
                }
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }
    }
}
